<template>
	<uni-search-bar @confirm="toSearch" placeholder="请输入搜索的公交地铁线路" v-model="searchkey"></uni-search-bar>
	<swiper style="height: 200px;" :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
		<swiper-item v-for="(item,index) in lunboList" :key="index">
			<view class="swiper-item">
				<image style="width: 100%;" :src="item.url" mode=""></image>
			</view>
		</swiper-item>
		</swiper>
</template>

<script setup>
	import{
		onLoad
	}from"@dcloudio/uni-app"
	import{
		ref
	}from 'vue'
import {
	CONFIG,
	} from "../../utils/config";
	
	const searchkey = ref("")
	function toSearch()
	{
		if(searchkey.value=="")
		{
			uni.showToast({
				title:"请输入查询的公交地图线路",
				icon:"none"
			})
		}else{
				  window.location.href =
				    `https://uri.amap.com/line?name=${searchkey.value}&city=029&callnative=0`
		}
	}
	onLoad(() => {
		getlunbo()
	})
	
	const lunboList = ref([])
	
async	function getlunbo(){
	let res = await	uni.$get(CONFIG.leanCloud_url+"/1.1/classes/lunbo")
	if(res.statusCode==200)
	{
		lunboList.value = res.data.results
	}
	console.log(lunboList.value)
	}
	function getCurrentPos(){
		uni.getLocation({
			success:function(res){
				console.log('当前位置的经度：'+res.longitude);
				console.log('当前位置的纬度：'+res.latitude);
			}
		})
	}
</script>
<style lang="scss" scoped>
	
</style>
